package edu.API;

public class RunTimePra {
    public static void main(String[] args) {
        //找api（看源码）
        Runtime runtime = Runtime.getRuntime();
        //获取jvm的最大内存  b
        long maxMemory = runtime.maxMemory();
        System.out.println("maxMemory = " + maxMemory);
        //获取jvm的空闲内存
        long freeMemory = runtime.freeMemory();
        System.out.println("freeMemory = " + freeMemory);
        String s = "s";
        for (int i = 0; i < 10000; i++) {
            s += i;
        }
        //gc自动执行了
        long freeMemory2 = runtime.freeMemory();
        System.out.println("freeMemory2 = " + freeMemory2);
        //gc  garbage collector   垃圾回收   jvm  垃圾回收机制
//        runtime.gc();

    }


}
